package com.learning.controller.teacher;

import com.learning.dto.ExamPaperQuestionDTO;
import com.learning.result.Result;
import com.learning.service.IExamPaperQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 管理试卷中的题目 前端控制器
 *
 * @author mhdtkc
 * @since 2025-5-25
 */
@Api(tags = "试卷中的题目相关接口")
@RestController
@RequestMapping("/teacher/examPaperQuestion")
public class ExamPaperQuestionController {

    @Autowired
    private IExamPaperQuestionService examPaperQuestionService;


    /**
     * 手动添加题目
     *
     * @param examPaperQuestionDTO
     * @return
     */
    @ApiOperation("手动添加题目")
    @PostMapping
    public Result addQuestion(@RequestBody ExamPaperQuestionDTO examPaperQuestionDTO){
        examPaperQuestionService.addQuestion(examPaperQuestionDTO);
        return Result.success();
    }


    /**
     * 根据试卷id和题目id删除试卷的题目
     * @param examPaperId
     * @param questionId
     * @return
     */
    @ApiOperation("删除试卷的题目")
    @DeleteMapping("/{examPaperId}/{questionId}")
    public Result delete(@PathVariable(value = "examPaperId") Long examPaperId,
                             @PathVariable(value = "questionId") Long questionId){
        examPaperQuestionService.subQuestion(examPaperId, questionId);
        return Result.success();
    }
}
